package com.yunhe.estatemanage.controller;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.estatemanage.domain.IncidentSatisfactionTable;
import com.yunhe.estatemanage.service.IncidentSatisfactionTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunhe.common.model.ResultObject;

/**
 * @description 事件满意度表
 * @author misty
 * @date 2021-09-06
 */
@Api(value = "IncidentSatisfactionTable", description = "事件满意度表维护", tags = {"Model_IncidentSatisfactionTable"})
@RestController
@RequestMapping(value = "/incidentSatisfactionTable")
public class IncidentSatisfactionTableController {

    @Autowired
    private IncidentSatisfactionTableService incidentSatisfactionTableService;

    /**
     * 新增
     * @author misty
     * @date 2021/09/06
     **/
    @ApiOperation("新增事件满意度表")
    @PostMapping("/createIncidentSatisfactionTable")
    public ResponseEntity<ResultObject> createIncidentSatisfactionTable(@RequestBody IncidentSatisfactionTable incidentSatisfactionTable) throws ArgumentErrorException {
        incidentSatisfactionTableService.createIncidentSatisfactionTable(incidentSatisfactionTable);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    /**
     * 刪除
     * @author misty
     * @date 2021/09/06
     **/
    @ApiOperation("根据id删除事件满意度表")
    @DeleteMapping("/deleteIncidentSatisfactionTable")
    public ResponseEntity<ResultObject> deleteIncidentSatisfactionTable(@RequestParam(value = "id",required = true) int id){
        incidentSatisfactionTableService.deleteIncidentSatisfactionTable(id);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    /**
     * 更新
     * @author misty
     * @date 2021/09/06
     **/
    @ApiOperation("更新事件满意度表")
    @PostMapping("/updateIncidentSatisfactionTable")
    public ResponseEntity<ResultObject> updateIncidentSatisfactionTable(@RequestBody IncidentSatisfactionTable incidentSatisfactionTable){
        incidentSatisfactionTableService.updateIncidentSatisfactionTable(incidentSatisfactionTable);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    /**
     * 查询 根据主键 id 查询
     * @author misty
     * @date 2021/09/06
     **/
    @ApiOperation("根据id查询事件满意度表")
    @GetMapping("/findIncidentSatisfactionTableById")
    public ResponseEntity<ResultObject<IncidentSatisfactionTable>> findIncidentSatisfactionTableById(@RequestParam(value = "id",required = true) int id){
        return new ResponseEntity<>(new ResultObject(incidentSatisfactionTableService.findIncidentSatisfactionTableById(id)),HttpStatus.OK);
    }

}